;Copy a selection set to a specified layer.
;
;	AUTHOR: HENRY C. FRANCIS
;		425 N. ASHE ST.
;		SOUTHERN PINES, NC 28387
;              
;		All rights reserved without prejudice.
;
;	Copyright:	3-19-96
;	Edited:		3-19-96
;
(defun c:ctol ( / ss ssl cnt ename ent nent pic8 new8)
  (setq ss (ssget)
        ssl (sslength ss)
        cnt 0
  );setq
  (if
    (setq pic8 (entsel "\nSelect entity on \"copy to\" layer or <enter> to key-in. "))
    (setq new8(cdr(assoc 8(entget(car pic8)))))
    (setq new8 (ustr 1 "\Enter layer name to copy to. " (getvar"clayer") nil))
  );if
  (if
    (tblsearch "LAYER" new8)
    nil
    (command ".layer" "m" new8 "")
  );if
  (while (< cnt ssl)
    (setq ename (ssname ss cnt)
          ent (entget ename)
          nent
            (cdr
              (subst (cons 8 new8)
              (assoc 8 ent)
              ent)
            );cdr
          cnt (1+ cnt)
    );setq
    (if
      (and
        (not(eq "POLYLINE" (cdr(assoc 0 ent))))
        (not(eq "INSERT" (cdr(assoc 0 ent))))
      );and
      (entmake nent)
      (progn
        (command ".copy" ename "" (list 0 0 0) "")
        (setq ent (entget(entlast))
              ent
                (subst
                  (cons 8 new8)
                  (assoc 8 ent)
                  ent
                )
        );setq
        (entmod ent)
      );progn
    );if
  );while
  (princ)
);defun    
